<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>我的奖品</title>
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="viewport" id="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1,user-scalable=no" />
		<meta name="format-detection" content="telephone=no" />
		<meta content="true" name="apple-mobile-web-app-capable" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style" />
		<link rel="stylesheet" type="text/css" href="css/style.css?v=1" />
		<link rel="stylesheet" type="text/css" href="css/page.css" />
		<script type="text/javascript" src="js/jquery-3.1.1.js"></script>
		<script>
			function set_meta() {
				var body_width = document.documentElement.clientWidth;
				//var body_height = document.documentElement.clientHeight;
				var get_scale = (body_width) / 750;

				var get_content = "width=device-width, initial-scale=" + get_scale + ", minimum-scale=" + get_scale + ", maximum-scale=" + get_scale + ", user-scalable=no";
				document.getElementById("viewport").setAttribute('content', get_content);

			}
			set_meta();
		</script>
	</head>

	<body class="bg1">

		<div class="tabbtn">
			<ul class="flex">
				<li class="flex-1 ">
					<a href="javascript:;" class="active">优惠券</a>
				</li>
				<li class="flex-1">
					<a href="javascript:;">实物奖品</a>
				</li>
			</ul>
		</div>
		<div class="card block" id = "coupon">
			<!--<div class="cardbox mt20">
				<div class="bg2 clearfix">
					<div class="imgbox ">
					<img class="inline-block imgbox" src="img/brand.png" />
					</div>
					<label class="inline-block">
						<p>蒙牛常温奶</p>
						<p class="sale">满<font class="price">30</font>元可用</p>
					</label>
					<div class="viewopt fr">
						<p class="text-center">￥
							<font class="price">5</font>
						</p>
						<button class="btn view">查看</button>
					</div>
				</div>
				<div class="bg1">
					<p>蒙牛常温奶(除特仑苏纯牛奶、精选纯10支装和250ml纯牛奶)</p>
				</div>
			</div>
			<div class="cardbox mt20">
				<div class="bg2 clearfix">
					<img class="imgbox inline-block" src="img/brand.png" />
					<label class="inline-block">
						<p>蒙牛常温奶</p>
						<p class="sale">满<font class="price">50</font>元可用</p>
					</label>
					<div class="viewopt fr">
						<p class="text-center">￥
							<font class="price">10</font>
						</p>
						<button class="btn view">查看</button>
					</div>
				</div>
			</div>
			<div class="cardbox mt20">
				<div class="bg2 clearfix ">
					<img class="imgbox inline-block" src="img/brand.png" />
					<label class="inline-block">
						<p>蒙牛ZUO风味酸奶</p>
						<p>蒙牛常温奶</p>
						<p class="sale">新品兑换券</p>
					</label>
					<div class="viewopt fr">
						<button class="btn view mt20">兑换</button>
					</div>
				</div>
				<div class="bg1">
					<p>凭此券至活动门店蒙牛促销员处兑换相应实物，由促销员点击“领取”按钮，完成兑换流程。如用户自行点击“领取”按钮，视为此券失效。</p>
				</div>
			</div>-->
		</div>
		<div class="card reward">
			<div class="opbtn text-center flex ml30 mr30" style="margin-top: 40px;">
				<!--<button class="btn save flex-1">管理地址</button>-->
				<a href="address.html" class="btn save flex-1" style="padding: 30px 0;font-size: 36px;">管理地址</a>
			</div>
			<div class="cardbox mt20" id = "entity">
				<!--<div class="bg2 clearfix  ml30 mr30 flex">
					<img class="imgbox inline-block" src="img/goods2.png" />
					<label class="inline-block flex-1">
						<p>2018年俄罗斯世界杯吉祥物吉祥物玩偶1个</p>
						<p class="sale">有效日期：<font >2018.5.20-6.23</font></p>
					</label>
				</div>-->
				<!--<ul class="ml30 mr30">
					<li class="flex">
						<img src="img/goods2.png" />
						<label class="flex-1">
							<p class="title">2018年俄罗斯世界杯吉祥物吉祥物玩偶1个</p>
							<p class="date">有效日期：<font >2018.5.20-6.23</font></p>
						</label>
					</li>
				</ul>-->
			</div>
	</body>

</html>
<script src="js/jweixin-1.0.0.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery-3.1.1.js" type="text/javascript" charset="utf-8"></script>
<script src="https://res.wx.qq.com/mmbizwap/zh_CN/htmledition/js/vconsole/2.5.1/vconsole.min.js"></script>
<script src="js/md5.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.eraser.js" type="text/javascript" charset="utf-8"></script>
<script src="js/index.js?v=16" type="text/javascript" charset="utf-8"></script>

<script>
	$(function() {
		var entity=getQueryString("channel")||'';
		// if(entity.length){
		// 	$('.tabbtn ul li a.active').removeClass("active");
		// 	$('.tabbtn ul li a').eq(1).addClass("active");
		// 	$("#coupon").hide();
		// 	$(".reward").show();
		// }else{
		// 	$('.tabbtn ul li a.active').removeClass("active");
		// 	$('.tabbtn ul li a').eq(0).addClass("active");
		// 	$("#coupon").show();
		// 	$(".reward").hide();
		// }
		$(".tabbtn ul li").click(function() {
			$('.tabbtn ul li a.active').removeClass("active");
			$(this).find('a').addClass("active");
			var index = $(this).index();
			$(".card").eq(index).addClass("block").siblings().removeClass('block');
		});
		_getOpenid(function(res){
			/*查询优惠券*/
		queryMyCoupon(Openid,function(data){
			console.log("我的优惠券数据"+JSON.stringify(data))
			if(parseInt(data.code)==200){
				if(data.data.length){

					var couponlist =  data.data;
					var html = "";
					for(var i = 0; i < couponlist.length; i++ ){
						html  = '<div class="cardbox mt20"> ';
						html  += '	<div class="bg2 clearfix"> ';
						html  += '				<img class="inline-block imgbox" src="'+couponlist[i].logo_url+'" /> ';
						html  += '				<label class="inline-block"> ';
						html  += '					<p>'+couponlist[i].coupon_name+'</p> ';
						html  += '					<p class="sale">满<font class="price">'+couponlist[i].coupon_fee+'</font>元可用</p> ';
						html  += '				</label> ';
						html  += '				<div class="viewopt fr"> ';
						html  += '					<p class="text-center">￥ ';
						html  += '						<font class="price">'+couponlist[i].coupon_fee+'</font> ';
						html  += '					</p> ';
						html  += '					<a class="btn view" href="'+couponlist[i].get_coupon_link+'">查看</a> ';
						html  += '				</div> ';
						html  += '			</div> ';
						html  += '			<div class="bg1"> ';
						html  += '				<p>'+couponlist[i].rule+'</p> ';
						html  += '			</div> ';
						html  += '		</div>';
					}	
					$("#coupon").html(html);
				}else{
					console.log("暂时还未可用优惠券")
				}
			}else{
				console.log(data.msg);
			}
		});
		/*获取实物*/
		queryEntityPrize(Openid,function(data){
			if(parseInt(data.code) == 200){
				var html = "";
				if( parseInt(data.data[0].type)==2){
					html = '<ul class="ml30 mr30">';
					html += '<li class="flex">';
					html += '	<img src="img/entity.png" />';
					html += '	<label class="flex-1">';
					html += '		<p class="title">2018年俄罗斯世界杯吉祥物吉祥物玩偶1个</p>';
					html += '		<p class="date">有效日期：<font >'+data.data[0].create_time+'</font></p>';
					html += '	</label>';
					html += '</li>';
				    html += '</ul>';
					$("#entity").html(html);
				}
			}else{	
				console.log(data.msg);
			}
		})	
		/*分享*/
		getWxJsApi(false);
		})
		
	})
</script>